<template>
  <j-modal
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    :title="title"
    :visible="visible"
    :width="width"
    switchFullscreen
    @cancel="handleCancel"
  >
    <template slot="footer">
      <a-button v-if="editStatus == false" key="submit" :loading="confirmLoading" type="primary" @click="handleOk">
        提交
      </a-button>
      <a-button v-if="editStatus == true && current !== 1 && current !== 3" key="submit" :loading="confirmLoading"
                type="primary"
                @click="handleEdit">
        确认
      </a-button>
      <a-button
        v-if="editStatus == true && current == 3 && checkList.currentStep < totalStep && isChecked == false"
        key="submit"
        :loading="confirmLoading" type="primary"
        @click="handleCheck(0)">
        提交审批
      </a-button>
      <a-button
        v-if="editStatus == true && current == 3 && checkList.currentStep == totalStep && isChecked == false"
        key="submit"
        :loading="confirmLoading" type="primary"
        @click="handleCheck(1)">
        结束流程
      </a-button>
      <a-button v-if="editStatus == true && current == 1 && checkList.finished == '审批已通过'"
                key="submit" :disabled="signed" :loading="confirmLoading" type="primary"
                @click="confirmSigned">
        线下已签订
      </a-button>

    </template>
    <a-spin :spinning="confirmLoading" style="margin: 0 40px">
      <!--      <a-steps :current="current" size="small">-->
      <!--        <a-step title="填写信息"/>-->
      <!--        <a-step title="生成订单"/>-->
      <!--      </a-steps>-->
      <!--      <div v-if="current == 0" class="steps-content">-->
      <div v-if="current == 0 || current == 2 || current == 4">
        <!--          style="margin-top: 20px; "-->
        <a-form-model
          ref="ruleForm"
          :label-col="labelCol"
          :model="model"
          :rules="rules" :wrapper-col="wrapperCol"
        >
          <a-row style="margin: 10px 0">
            <h2>基本信息：</h2>
          </a-row>
          <a-row justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="购车人名称" prop="name">
                <a-input v-model="model.name" allow-clear placeholder="请输入购车人姓名"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="购车人证件类型" prop="certType">
                <a-select v-model="model.certType" placeholder="请选择购车人证件类型" @change="changeRegExp">
                  <a-select-option value="1">
                    身份证
                  </a-select-option>
                  <a-select-option value="2">
                    护照
                  </a-select-option>
                  <a-select-option value="3">
                    士官证
                  </a-select-option>
                  <a-select-option value="4">
                    居住证
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="购车人证件号码" prop="certNo">
                <a-input v-model="model.certNo" allow-clear placeholder="请输入购车人证件号码"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="购车人手机号码" prop="contactPhone">
                <a-input v-model="model.contactPhone" allow-clear placeholder="请输入购车人手机号码"></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row style="margin: 10px 0">
            <h2>订单信息：</h2>
          </a-row>
          <a-row justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="识别代码(VIN)" prop="vin">
                <a-input v-model="model.vin" allow-clear placeholder="请输入识别代码" @change="checkVin"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="品牌名称" prop="brand">
                <a-select v-model="model.brand" placeholder="请选择品牌名称" @change="handleBrandChange">
                  <a-select-option v-for="(item, index) in brandList" :key="index" :value="item.name">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="车辆型号" prop="carModel">
                <a-select v-model="model.carModel" :disabled="selectDisabled" placeholder="请选择车辆型号" @change="getVin">
                  <a-select-option v-for="(item, index) in modelList" :key="index" :value="item.name">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="车辆颜色" prop="outsideColor">
                <a-select v-model="model.outsideColor" :disabled="selectDisabled" placeholder="请选择内饰颜色"
                          @change="getVin">
                  <a-select-option v-for="(item, index) in outsideColorList" :key="index" :value="item.name">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="内饰颜色" prop="interiorColor">
                <a-select v-model="model.interiorColor" :disabled="selectDisabled" placeholder="请选择内饰颜色"
                          @change="getVin">
                  <a-select-option v-for="(item, index) in interiorColorList" :key="index" :value="item.name">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="销售人员" prop="sellerId">
                <a-select v-model="model.sellerId" placeholder="请选择销售人员"
                          @change="">
                  <a-select-option v-for="(item, index) in sellerList" :key="index" :value="item.id">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row style="margin: 10px 0">
            <h2>价格信息：</h2>
          </a-row>
          <a-row justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="订金类型" prop="depositType">
                <a-select v-model="model.depositType" placeholder="请选择订金类型">
                  <a-select-option value="1">
                    可退
                  </a-select-option>
                  <a-select-option value="2">
                    不可退
                  </a-select-option>
                  <a-select-option value="3">
                    有条件可退
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="订金" prop="deposit">
                <a-input-number
                  v-model="model.deposit"
                  :formatter="value => `￥ ${value}`"
                  :min="0"
                  style="width: 100%"
                />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="订单描述" prop="depositAgreement">
                <a-textarea v-model="model.depositAgreement" :autosize="{minRows: 4, maxRows: 6}" allow-clear
                            placeholder="请输入订金描述" style="width: 290%"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="车辆售价" prop="price">
                <a-input-number
                  v-model="model.price"
                  :formatter="value => `￥ ${value}`"
                  :min="0"
                  style="width: 100%"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="是否代办服务" prop="isAgency">
                <a-radio-group v-model="model.isAgency">
                  <a-radio :value="1">
                    是
                  </a-radio>
                  <a-radio :value="0">
                    无
                  </a-radio>
                </a-radio-group>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.isAgency == 1" :span="11">
              <a-form-model-item label="代办服务名称" prop="agencyName">
                <a-input v-model="model.agencyName" allow-clear placeholder="请输入代办服务名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.isAgency == 1" :span="11">
              <a-form-model-item label="代办服务费" prop="otherFees">
                <a-input-number
                  v-model="model.otherFees"
                  :formatter="value => `￥ ${value}`"
                  :min="0"
                  style="width: 100%"
                />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row v-if="model.isAgency == 1" justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="备注" prop="agencyRemarks">
                <a-textarea v-model="model.agencyRemarks" :autosize="{minRows: 4, maxRows: 6}" allow-clear
                            placeholder="请输入备注" style="width: 290%"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row v-if="current == 0" style="margin: 10px 0">
            <h2>发票信息：</h2>
          </a-row>
          <a-row v-if="current == 0" justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="发票类型" prop="invoiceType">
                <a-radio-group v-model="model.invoiceType" @change="onChangeInvoiceType">
                  <a-radio :value="1">
                    个人
                  </a-radio>
                  <a-radio :value="2">
                    单位
                  </a-radio>
                  <a-radio :value="0">
                    暂不开票
                  </a-radio>
                </a-radio-group>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 1" :span="11">
              <a-form-model-item label="开票人" prop="taxPayer">
                <a-input v-model="model.taxPayer" allow-clear placeholder="请输入开票人"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 1" :span="11">
              <a-form-model-item label="开票人联系方式" prop="taxPayerPhone">
                <a-input v-model="model.taxPayerPhone" allow-clear placeholder="请输入开票人联系方式"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 1" :span="11">
              <a-form-model-item label="开票人证件号" prop="taxPayerId">
                <a-input v-model="model.taxPayerId" allow-clear placeholder="请输入开票人证件号"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 2" :span="11">
              <a-form-model-item label="单位名称" prop="taxPayer">
                <a-input v-model="model.taxPayer" allow-clear placeholder="请输入单位名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 2" :span="11">
              <a-form-model-item label="纳税人识别号" prop="taxPayerId">
                <a-input v-model="model.taxPayerId" allow-clear placeholder="请输入纳税人识别号"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 2" :span="11">
              <a-form-model-item label="开户银行" prop="taxPayerBank">
                <a-input v-model="model.taxPayerBank" allow-clear placeholder="请输入开户银行"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 2" :span="11">
              <a-form-model-item label="银行账号" prop="taxPayerBankAccount">
                <a-input v-model="model.taxPayerBankAccount" allow-clear placeholder="请输入银行账号"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="model.invoiceType == 2" :span="11">
              <a-form-model-item label="收票人手机" prop="taxPayerPhone">
                <a-input v-model="model.taxPayerPhone" allow-clear placeholder="请输入收票人手机"></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row style="margin: 10px 0">
            <h2>交车信息：</h2>
          </a-row>
          <a-row justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="车辆交付日期" prop="deliveryTime">
                <a-input v-model="model.deliveryTime" allow-clear placeholder="请输入车辆交付日期"></a-input>
                <!--                <a-date-picker-->
                <!--                  v-model="model.deliveryTime"-->
                <!--                  format="YYYY-MM-DD"-->
                <!--                  style="width: 100%"-->
                <!--                  @openChange="onChangeDeliverDate"-->
                <!--                />-->
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item label="交车地点" prop="deliveryPlace">
                <a-input v-model="model.deliveryPlace" allow-clear placeholder="请输入交车地点"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col v-if="current !== 4 && current == 0" :span="11">
              <a-form-model-item label="审批人" prop="step">
                <a-select v-model="model.step" placeholder="请选择审批人">
                  <a-select-option v-for="(item, index) in stepList" :key="index" :value="item.id">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
        <a-form-model
          :label-col="{span: 4}"
          :model="model"
          :wrapper-col="{span: 20}"
        >
          <a-row justify="space-between" type="flex">
            <a-col :span="22">
              <a-form-model-item label="备注" prop="remarks">
                <a-textarea v-model="model.remarks" :autosize="{minRows: 4, maxRows: 6}" allow-clear
                            placeholder="请输入备注" style="width: 108.5%"/>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
      <!--      </div>-->
      <div v-if="current == 1 || current == 3" class="steps-content">
        <div class="form" style="background-color: white;padding: 20px 30px;border-radius: 5px;">
          <!--顶部左右部分-->
          <a-row class="form" justify="space-between" type="flex">
            <a-col :span="8" class="formTopLeft">
              订购日期：{{ model.deliveryTime }}
            </a-col>
            <a-col :span="8" class="formTopLeft" style="text-align: right;">
              客户订单编号：{{ model.id }}
            </a-col>
          </a-row>
          <!--表内开始-->
          <div style="margin: 5px 0">
            <a-row class="formBorder1st">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                购车人名称
              </a-col>
              <a-col :span="9" class="notRight formInlineHeight">
                {{ model.name }}
              </a-col>
              <a-col :span="6" class="notRight formInlineHeight" style="text-align: right">
                手机号码
              </a-col>
              <a-col :span="6" class="formInlineHeight">
                {{ model.contactPhone }}
              </a-col>
            </a-row>
            <!--第三行-->
            <a-row class="formBorder">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                证件类型
              </a-col>
              <a-col :span="9" class="notRight formInlineHeight">
                {{ model.certType }}
              </a-col>
              <a-col :span="6" class="notRight formInlineHeight" style="text-align: right">
                证件号码
              </a-col>
              <a-col :span="6" class="formInlineHeight">
                {{ model.certNo }}
              </a-col>
            </a-row>
            <!--   车辆基本信息     -->
            <a-row class="formBorder">
              <a-col :span="24" class="formInlineHeight" style="text-align: center;font-size: 16px;color: black">
                车辆基本信息
              </a-col>
            </a-row>
            <!--    基本要求line1      -->
            <a-row class="formBorder">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                识别代码(VIN)
              </a-col>
              <a-col :span="9" class="notRight formInlineHeight">
                {{ model.vin }}
              </a-col>
              <a-col :span="6" class="notRight formInlineHeight" style="text-align: right">
                品牌名称
              </a-col>
              <a-col :span="6" class="formInlineHeight">
                {{ model.brand }}
              </a-col>
            </a-row>
            <a-row class="formBorder">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                车辆型号
              </a-col>
              <a-col :span="9" class="notRight formInlineHeight">
                {{ model.carModel }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                车辆颜色要求
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.outsideColor }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                内饰颜色要求
              </a-col>
              <a-col :span="3" class=" formInlineHeight">
                {{ model.interiorColor }}
              </a-col>
            </a-row>
            <!--价格-->
            <a-row class="formBorder">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right;">
                是否代办服务
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.isAgency }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                代办服务名称
              </a-col>
              <a-col :span="9" class="notRight formInlineHeight">
                {{ model.agencyName }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                代办服务费
              </a-col>
              <a-col :span="3" class="formInlineHeight">
                {{ model.otherFees }}
              </a-col>
            </a-row>
            <a-row class="formBorder" style="height: 50px;">
              <a-col :span="3" class="notRight formInlineHeight_high" style="text-align: right;line-height: 43px;">
                代办服务备注
              </a-col>
              <a-col :span="21" class="formInlineHeight_high"
                     style="position: relative;top: 50%;transform: translateY(-50%);">
                {{ model.agencyRemarks }}
              </a-col>
            </a-row>
            <a-row class="formBorder">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                车辆销售价(元)
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.price }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                开票类型
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.invoiceType }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                订金(元)
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.deposit }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                订金类型
              </a-col>
              <a-col :span="3" class="formInlineHeight">
                {{ model.depositType }}
              </a-col>
            </a-row>
            <a-row class="formBorder" style="height: 50px;">
              <a-col :span="3" class="notRight formInlineHeight_high" style="text-align: right;line-height: 43px;">
                订金描述
              </a-col>
              <a-col :span="21" class="formInlineHeight_high"
                     style="position: relative;top: 50%;transform: translateY(-50%);">
                {{ model.depositAgreement }}
              </a-col>
            </a-row>
            <a-row class="formBorder" style="display: flex;width: 100%">
              <a-col :span="3" class="formInlineHeight_high notRight" style="text-align: right;">
                补充协议
              </a-col>
              <a-col :span="21" class="formInlineHeight_high" style="padding: 10px;">
                1、质量要求技术标准:按中华人民共和国标准《机动车安全运行技术条件》(GB7258-2017)文件规定及汽车厂三包规定执行: 因车辆
                受机动车公告限制，购车人延期提车或提车后不立即上牌，因公告过期造成车辆无法上牌的损失由购车人自行承担，
                车辆销售单位不承担任何责任;<br/>
                2、验收标准、方法及提出异议期限:按照合同订单配置交付车辆，购车人签收提车即视为车辆符合要求无异议;<br/>
                3、购车人必须在约定的交付时间内缴纳剩余车款并提车，逾期不办理提车和补交余款，
                视为购车人违约，经销商可以将购车人订购车辆优先销售给其他客户，经销商给购车人重新更换相同配置的车辆，
                因购车客户的原因造成延期交付车辆，责任全部由购车客户负责，经销商不承招讳约责任;<br/>
                4、购车人到汽车厂家自提车辆时，车辆及途中安全责任由购车人自行负责，经销商不承担任何责任;<br/>
                5、标的物所有权:标的物所有权自购车人付清全部车款时转移，若购车人未履行支付全部车款义务，
                贷款购车的资金暂时未到账，车辆所有权属于经销商，经销商必须收到车辆的全部车款及相关费用才能向购车人交付车辆;<br/>
                6、本合同签订后，需经销商加盖公司印章，购车客户按照合同付款时订单即刻生效，公司将给客户开具缴款收据，
                缴款收据作为购车客户订车生效凭据:合同签订后若客户未按照约定项目缴款，本订单无效;<br/>
                7、双方保证合同中提供的通许地址联系电话真实可靠，作为双方签收各项文书的法律依据(包含诉状、
                保险单、信画、车辆发票车辆合格证等)，因为其中一方通讯地址或联系方式发生改变，造成无法签收时，
                均视为送达;<br/>
                8、违约责任及解决合同纠纷方式:本合同严格按照购车人的要求订购，
                若因购车人在约定的车辆交付时间内不提车，不支付车辆余款，视为购车人违约，
                购车人自愿终止合同不愿意再继续展行购车合同，双方无需另行申明:对此，经销商不再受合同的约束，
                但购车人必须按照下列要求向经销商承担相应的责任:A、购车人给经销商造成的实际经济损失小于或等于订金时，
                经销商收取的订金不再退还:B、购车人给经销商造成的实际经济损失大于订金时，经销商收取的订金不再退还外，
                购车人还应赔偿经销商的实际经济损失;C双方确认实际经济损失包括但不限于车辆的改装费、车辆保管费(停车费)、
                车辆上牌发生的费用、以及诉讼发生的律师费等;<br/>
                9、解决争议方式:双方协商解决，协商不成由经销商所在地人民法院提起诉讼，双方不持异议;
              </a-col>
            </a-row>
            <a-row class="formBorder">
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                销售员
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.seller }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                汽车销售部门
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">
                {{ model.sellDepartment }}
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                主管签字
              </a-col>
              <a-col :span="3" class="notRight formInlineHeight">

              </a-col>
              <a-col :span="3" class="notRight formInlineHeight" style="text-align: right">
                用户签字
              </a-col>
              <a-col :span="3" class="formInlineHeight">

              </a-col>
            </a-row>
          </div>
          <!--          <a-row class="form" justify="space-between" type="flex">-->
          <!--            <a-col :span="4" class="formTopLeft">-->
          <!--              修改日期：{{ }}-->
          <!--            </a-col>-->
          <!--            <a-col :span="4" class="formTopLeft" style="text-align: right">-->
          <!--              修改人：{{ }}-->
          <!--            </a-col>-->
          <!--          </a-row>-->
        </div>
        <a-form-model
          v-if="current == 3"
          ref="ruleForm"
          :label-col="labelCol"
          :model="model" :rules="rules"
          :wrapper-col="wrapperCol"
        >
          <a-row v-if="checkList.currentStep > 1" style="margin: 10px 0">
            <h2>历史审批信息：</h2>
          </a-row>
          <div v-for="(item, index) in actionList" :key="index"
               style="background-color: #f9f9f9;border-radius: 10px;padding: 10px 0 0;margin-bottom: 10px;">
            <a-row justify="space-between" type="flex">
              <a-col :span="11">
                <a-form-model-item label="审核人" prop="action">
                  {{ item.doneBy }}
                </a-form-model-item>
              </a-col>
              <a-col :span="11">
                <a-form-model-item label="审核操作" prop="action">
                  {{ item.action }}
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row justify="space-between" type="flex">
              <a-col :span="11">
                <a-form-model-item label="批注" prop="comment">
                  <a-textarea v-model="item.comment" :autosize="{minRows: 4, maxRows: 6}" :read-only="true"
                              allow-clear placeholder="请输入批注" style="width: 290%"/>
                </a-form-model-item>
              </a-col>
            </a-row>
          </div>
          <a-row v-if="isChecked == false" style="margin: 10px 0">
            <h2>审批信息：</h2>
          </a-row>
          <a-row v-if="isChecked == false" justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="审核操作" prop="action">
                <a-radio-group v-model="check.action">
                  <a-radio :value="1">
                    通过
                  </a-radio>
                  <a-radio :value="2">
                    驳回
                  </a-radio>
                </a-radio-group>
              </a-form-model-item>
            </a-col>
            <a-col :span="11">
              <a-form-model-item v-if="checkList.currentStep < totalStep" label="下一审批人" prop="next">
                <a-select v-model="check.nextId" placeholder="请选择下一审批人">
                  <a-select-option v-for="(item, index) in stepList" :key="index" :value="item.id">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row v-if="isChecked == false" justify="space-between" type="flex">
            <a-col :span="11">
              <a-form-model-item label="批注" prop="comment">
                <a-textarea v-model="check.comment" :autosize="{minRows: 4, maxRows: 6}" allow-clear
                            placeholder="请输入批注" style="width: 290%"/>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
    </a-spin>
    <!--    <a-button type="primary" @click="saveDraft">暂存</a-button>-->
  </j-modal>
</template>

<script>
import { getAction, httpAction, postAction } from '@/api/manage'
import moment from 'moment'

export default {
  name: 'SalesRegisterModel',
  data() {
    return {
      signed: false,
      isChecked: false,
      finished: '',
      checkList: [],
      sellerList: [],
      totalStep: '',
      check: {},
      selectDisabled: true,
      brandList: [],
      modelList: [],
      outsideColorList: [],
      interiorColorList: [],
      actionList: [],
      stepList: [],
      editStatus: false,
      width: 1000,
      current: '',
      value: '',
      title: '交易信息',
      visible: false,
      model: {},
      loading: '',
      saleSource: [],
      SaleInfosLike: [],
      labelCol: {
        span: 8
      },
      wrapperCol: {
        span: 15
      },
      rules:
        {
          //车管验证条件
          orderType: [{ required: true, message: '请选择订单类型', trigger: 'blur' }],
          name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
          certType: [{ required: true, message: '请选择证件类型', trigger: 'blur' }],
          certNo: [{ required: true, message: '请输入证件号码', trigger: 'blur' }],
          contactPhone: [{ required: true, message: '请输入购车人手机号码', trigger: 'blur' }, {
            message: '请输入正确的手机号码',
            pattern: new RegExp(/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
            )
          }],
          vin: [],
          depositType: [{ required: true, message: '请选择订金类型', trigger: 'blur' }],
          deposit: [{ required: true, message: '请输入订金', trigger: 'blur' }],
          depositAgreement: [{ required: true, message: '请输入订金描述', trigger: 'blur' }],
          isAgency: [{ required: true, message: '请选择是否需要代办服务', trigger: 'blur' }],
          agencyName: [{ required: true, message: '请输入代办服务名称', trigger: 'blur' }],
          otherFees: [{ required: true, message: '请输入代办服务费', trigger: 'blur' }],
          price: [],
          deliveryTime: [],
          deliveryPlace: [],
          brand: [{ required: true, message: '请选择品牌名称', trigger: 'blur' }],
          carModel: [{ required: true, message: '请选择车辆型号', trigger: 'blur' }],
          displacement: [{ required: true, message: '请选择发动机排量', trigger: 'blur' }],
          outsideColor: [{ required: true, message: '请选择车辆颜色', trigger: 'blur' }],
          interiorColor: [{ required: true, message: '请选择内饰颜色', trigger: 'blur' }],
          sellerId: [{ required: true, message: '请选择销售人员', trigger: 'blur' }],
          invoiceType: [{ required: true, message: '请选择发票类型', trigger: 'blur' }],
          taxPayer: [{ required: true, message: '请输入必填项', trigger: 'blur' }],
          taxPayerPhone: [{ required: true, message: '请输入必填项', trigger: 'blur' }],
          taxPayerId: [{ required: true, message: '请输入必填项', trigger: 'blur' }],
          taxPayerBank: [{ required: true, message: '请输入必填项', trigger: 'blur' }],
          taxPayerBankAccount: [{ required: true, message: '请输入必填项', trigger: 'blur' }],
          step: [{ required: true, message: '请选择审批人', trigger: 'blur' }]
        },

      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {},
      url: {
        add: '/cxm/cxmOrderManager/add',
        edit: '/cxm/cxmOrderManager/edit',
        saveDraft: 'cxm/cxmCommonBusiness/saveDraft',
        getDraft: 'cxm/cxmCommonBusiness/getDraft',
        getSaleInfosLike: 'cxm/cxmSalesInfo/getSaleInfosLike',
        getSaleInfos: '/cxm/cxmOrderManager/getSaleInfos'
      },
      showDing: false,
      showEnterpriseUscc: false
    }
  },
  created() {
  },
  methods: {
    handleBrandChange(value) {
      if (this.model.carModel) {
        this.model.carModel = undefined
      }
      if (this.model.outsideColor) {
        this.model.outsideColor = undefined
      }
      if (this.model.interiorColor) {
        this.model.interiorColor = undefined
      }
      this.modelList = []
      this.outsideColorList = []
      this.interiorColorList = []
      this.getVin()
      getAction('/sale/cxmSaleBaseInfo/queryByType?dataType=' + 8 + '&parentName=' + value).then((res) => {
        console.log(res)
        if (res.success) {
          let data = res.result
          for (let i in data) {
            this.modelList.push(data[i])
          }
          this.selectDisabled = false
        }
      })
      getAction('/sale/cxmSaleBaseInfo/queryByTypes?dataTypes=' + '2,9').then((res) => {
        console.log(res)
        if (res.success) {
          let data1 = res.result[2]
          let data2 = res.result[9]
          for (let i in data1) {
            this.outsideColorList.push(data1[i])
          }
          for (let i in data2) {
            this.interiorColorList.push(data2[i])
          }
        }
      })
    },
    next() {
      this.$refs.ruleForm.validate(valid => {
        console.log(valid)
        if (valid) {
          this.current++
          if (this.model.orderDate) {
            this.model.orderDate = moment(this.model.orderDate._d).format('YYYY-MM-DD')
            console.log(this.model.orderDate)
          }

          // if (this.value == 0) {
          //   this.model.orderType = '库房现货'
          // } else if (this.value == 1) {
          //   this.model.orderType = '期货预定'
          // }

          this.width = 1300
        }
      })
    },
    onChangeInvoiceType() {
      this.$refs['ruleForm'].clearValidate(['taxPayer'])
      this.$refs['ruleForm'].clearValidate(['taxPayerPhone'])
      this.$refs['ruleForm'].clearValidate(['taxPayerId'])
      this.$refs['ruleForm'].clearValidate(['taxPayerBank'])
      this.$refs['ruleForm'].clearValidate(['taxPayerBankAccount'])
    },
    validate_Date() {
      this.$refs['ruleForm'].validateField('orderType')
    },

    onChangeDeliverDate() {
      setTimeout(this.validate_Date2, 100)
    },
    validate_Date2() {
      this.$refs['ruleForm'].validateField('deliveryTime')

    },
    checkVin() {
      if (!this.model.vin) {
        if (this.current !== 0) {
          this.rules.vin = []
          this.$refs['ruleForm'].clearValidate(['vin'])
        }
      } else {
        this.rules.vin = [{ required: true, message: '请输入证件号码', trigger: 'blur' }, {
          message: '请输入正确的VIN码',
          pattern: new RegExp(/^[A-HJ-NPR-Z\d]{17}$/)
        }]
        this.$refs['ruleForm'].validateField('vin')

        this.$refs.ruleForm.validateField('vin', valid => {
          if (!valid) {
            if (this.model.id) {
              getAction('/sale/cxmSaleCarInfo/queryCarByVin?vin=' + this.model.vin + '&orderId=' + this.model.id).then((res) => {
                console.log(res)
                if (res.success) {
                  this.$set(this.model, 'brand', res.result.brand)
                  this.$set(this.model, 'carModel', res.result.carModel)
                  this.$set(this.model, 'outsideColor', res.result.outsideColor)
                  this.$set(this.model, 'interiorColor', res.result.interiorColor)
                  // this.rules.vin = [{ required: true, message: '请输入识别代码', trigger: 'blur' }, {
                  //   message: '请输入正确的VIN码',
                  //   pattern: new RegExp(/^[A-HJ-NPR-Z\d]{17}$/)
                  // }]
                  // this.$refs['ruleForm'].validateField('vin')
                } else {
                  this.rules.vin = [{ required: true, message: '请输入证件号码', trigger: 'blur' }, {
                    message: res.message,
                    pattern: new RegExp(/^-[0-9]*[1-9][0-9]*$/)
                  }]
                  this.$refs['ruleForm'].validateField('vin')
                }
              })
            } else {
              getAction('/sale/cxmSaleCarInfo/queryCarByVin?vin=' + this.model.vin).then((res) => {
                console.log(res)
                if (res.success) {
                  this.$set(this.model, 'brand', res.result.brand)
                  this.$set(this.model, 'carModel', res.result.carModel)
                  this.$set(this.model, 'outsideColor', res.result.outsideColor)
                  this.$set(this.model, 'interiorColor', res.result.interiorColor)
                  this.selectDisabled = false
                  // this.rules.vin = [{ required: true, message: '请输入识别代码', trigger: 'blur' }, {
                  //   message: '请输入正确的VIN码',
                  //   pattern: new RegExp(/^[A-HJ-NPR-Z\d]{17}$/)
                  // }]
                  // this.$refs['ruleForm'].validateField('vin')
                } else {
                  this.rules.vin = [{ required: true, message: '请输入证件号码', trigger: 'blur' }, {
                    message: res.message,
                    pattern: new RegExp(/^-[0-9]*[1-9][0-9]*$/)
                  }]
                  this.$refs['ruleForm'].validateField('vin')
                }
              })
            }
          }
        })
      }
    },
    getVin() {
      if (this.model.brand && this.model.carModel && this.model.outsideColor && this.model.interiorColor) {
        getAction('/sale/cxmSaleCarInfo/queryVinByCar?brand=' + this.model.brand + '&carModel=' + this.model.carModel + '&outsideColor=' + this.model.outsideColor + '&interiorColor=' + this.model.interiorColor).then((res) => {
          console.log(res)
          if (res.success) {
            this.$set(this.model, 'vin', res.result[0])
          }
        })
      }
    },
    changeRegExp(value) {

      if (value == 1) {
        this.rules.certNo = [{ required: true, message: '请输入证件号码', trigger: 'blur' }, {
          message: '请输入正确的证件号码',
          pattern: new RegExp(/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/)
        }]
      } else if (value == 2) {
        this.rules.certNo = [{ required: true, message: '请输入证件号码', trigger: 'blur' }, {
          message: '请输入正确的证件号码',
          pattern: new RegExp(/^1[45][0-9]{7}|([P|p|S|s]\d{7})|([S|s|G|g]\d{8})|([Gg|Tt|Ss|Ll|Qq|Dd|Aa|Ff]\d{8})|([H|h|M|m]\d{8，10})$/)
        }]
        this.$refs['ruleForm'].validateField('certNo')
      } else if (value == 3) {
        this.rules.certNo = [{ required: true, message: '请输入证件号码', trigger: 'blur' }, {
          message: '请输入正确的证件号码',
          pattern: new RegExp(/^[a-zA-Z0-9]{7,21}$/)
        }]
        this.$refs['ruleForm'].validateField('certNo')
      }
    },
    add(value) {
      const that = this
      //获取value以区分当前新增是在订单还是合同环节
      this.model.orderType = value
      if (!this.model.brand) {
        this.selectDisabled = true
      } else {
        this.selectDisabled = false
        this.handleBrandChange(this.model.brand)
      }
      console.log(this.model.isAgency)
      if (this.model.orderType == 1) {
        // current的值在897行开始
        this.current = 4
        that.edit()
      } else if (this.model.orderType == 2) {
        this.current = 0
        this.isAddContract = true
        // 合同新增时，识别代码需要必填
        this.rules.vin = [{ required: true, message: '请输入识别代码', trigger: 'blur' }, {
          message: '请输入正确的VIN码',
          pattern: new RegExp(/^[A-HJ-NPR-Z\d]{17}$/)
        }]
        that.edit('', 0)
      } else {
        this.rules.vin = []
        that.edit()
      }
    },

    edit(record, value, total, checked) {
      // this.current == value
      // value = 0 转合同阶段 或 合同修改 或 合同新增
      // value = 1 合同阶段的合同表格查看
      // value = 2 订单修改
      // value = 3 审核阶段的审核以及查看
      // value = 4 订单新增
      this.form.resetFields()
      getAction('/sale/cxmSaleStaffInfo/queryStaffByAccount?isConfig=true').then((res) => {
        console.log(res)
        if (res.success) {
          this.sellerList = res.result
        }
      })
      // record只有在修改和转合同阶段才有值，通过判断record即可知道是在新增还是在修改
      if (record) {
        // 若修改，打开加载界面
        this.confirmLoading = true
        this.model.name = this.model.buyerName
        //若修改，保存修改状态为true
        this.editStatus = true
        this.selectDisabled = false
        //根据订单号查询详情
        let httpurl = ''
        console.log(record)
        if (value == 3) {
          httpurl = '/sale/cxmSaleOrderInfo/queryOrderInfo?id=' + record.contractId
          this.checkList = record
          this.totalStep = total
          if (checked) {
            this.isChecked = checked
          }
          console.log(this.isChecked)

        } else {
          httpurl = '/sale/cxmSaleOrderInfo/queryOrderInfo?id=' + record.id
        }
        getAction(httpurl).then((res) => {
          console.log(res)
          if (res.success) {
            this.model = Object.assign(res.result)
            // 下拉只认string
            this.model.certType = this.model.certType.toString()
            // 单选只认number
            this.model.invoiceType = Number(this.model.invoiceType)
            this.model.isAgency = Number(this.model.isAgency)
            this.model.depositType = this.model.depositType.toString()
            if (value == 1 || value == 3) {
              this.checkList = record
              if (value == 1 && record.finished == '审批已通过') {
                getAction('/sale/cxmSaleReceipt/queryComfirm?orderId=' + record.id).then((res) => {
                  console.log(res)
                  if (res.success) {
                    this.signed = true
                  } else {
                    this.signed = false
                  }
                })
              }
              this.finished = res.result.finished
              if (this.model.certType == 1) {
                this.model.certType = '身份证'
              } else if (this.model.certType == 2) {
                this.model.certType = '护照'
              } else if (this.model.certType == 3) {
                this.model.certType = '士官证'
              } else if (this.model.certType == 4) {
                this.model.certType = '居住证'
              }

              if (this.model.invoiceType == 1) {
                this.model.invoiceType = '个人'
              } else if (this.model.invoiceType == 2) {
                this.model.invoiceType = '单位'
              } else if (this.model.invoiceType == 0) {
                this.model.invoiceType = '暂不开票'
              }

              if (this.model.depositType == 1) {
                this.model.depositType = '可退'
              } else if (this.model.depositType == 2) {
                this.model.depositType = '不可退'
              } else if (this.model.depositType == 3) {
                this.model.depositType = '有条件可退'
              }

              if (this.model.isAgency == 1) {
                this.model.isAgency = '是'
              } else if (this.model.isAgency == 0) {
                this.model.isAgency = '无'
              }
              console.log(this.model.carModel)

              // let ids = this.model.brand + ',' + this.model.carModel + ',' + this.model.outsideColor + ',' + this.model.interiorColor
              // getAction('/sale/cxmSaleBaseInfo/queryByIds?ids=' + ids).then((res) => {
              //   console.log(res)
              //   if (res.success) {
              //     this.model.brand = res.result[1][0].name
              //     this.model.carModel = res.result[2][0].name
              //     this.model.outsideColor = res.result[8][0].name
              //     this.model.interiorColor = res.result[9][0].name
              //   }
              // })
            }
            getAction('/sale/cxmSaleBaseInfo/queryByType?dataType=' + 8 + '&parentName=' + this.model.brand).then((res) => {
              if (res.success) {
                let data = res.result
                for (let i in data) {
                  this.modelList.push(data[i])
                }
                this.selectDisabled = false
              }
            })
            getAction('/sale/cxmSaleBaseInfo/queryByTypes?dataTypes=' + '2,9').then((res) => {
              if (res.success) {
                this.confirmLoading = false
                let data1 = res.result[2]
                let data2 = res.result[9]
                for (let i in data1) {
                  this.outsideColorList.push(data1[i])
                }
                for (let i in data2) {
                  this.interiorColorList.push(data2[i])
                }
              }
            })
            //转合同时，获取审批人
            if (value == 0 || this.current == 0) {
              // getAction('/sale/cxmSaleProcessConfig/queryByStep?step=' + 1).then((res) => {
              //   if (res.success) {
              //     this.stepList = res.result
              //     console.log(this.stepList)
              //   } else {
              //     this.$message.warning(res.message)
              //   }
              // })
              // getAction('/sale/cxmSaleProcessAction/queryHandlerByProcessId?contactId=' + record.id).then((res) => {
              //   if (res.success) {
              //     console.log(res.result)
              //   }
              // })
            } else if (value == 3) {
              let next = record.currentStep
              if (next < this.totalStep) {
                next = next + 1
                getAction('/sale/cxmSaleProcessConfig/queryByStep?step=' + next).then((res) => {
                  if (res.success) {
                    this.stepList = res.result
                    console.log(this.stepList)
                  } else {
                    this.$message.warning(res.message)
                  }
                })
              }
              if (next !== 1) {
                getAction('/sale/cxmSaleProcessAction/queryByProcessId?processId=' + record.id).then((res) => {
                  console.log(res)
                  if (res.success) {
                    for (let i in res.result) {
                      getAction('/sale/cxmSaleStaffInfo/queryById?id=' + res.result[i].doneBy).then((re) => {
                        console.log(re)
                        if (re.success) {
                          res.result[i].doneBy = re.result.name
                          if (res.result[i].action == 1) {
                            res.result[i].action = '审核通过'
                          } else if (res.result[i].action == 2) {
                            res.result[i].action = '驳回'
                          }
                          this.actionList.push(res.result[i])
                        } else {
                          if (res.result[i].action == 1) {
                            res.result[i].action = '审核通过'
                          } else if (res.result[i].action == 2) {
                            res.result[i].action = '驳回'
                          }
                          this.actionList.push(res.result[i])
                        }
                      })
                    }
                  } else {
                    this.$message.warning(res.message)
                  }
                })
              }
            }
          } else {
            this.$message.warning(res.message + '，请稍候重试')
            setTimeout(() => {
              this.close()
            }, 2000)
          }
        })
        console.log(this.model.brand)
      }
      // 获取品牌列表
      getAction('/sale/cxmSaleBaseInfo/queryByTypes?dataTypes=' + 1).then((res) => {
        console.log(res)
        if (res.success) {
          let data = res.result
          for (let i in data[1]) {
            this.brandList.push(data[1][i])
          }
        }
      })
      console.log('当前订单（1）还是合同（2）：' + this.model.orderType)
      if (value == 0) {
        getAction('/sale/cxmSaleProcessConfig/queryByStep?step=' + 1).then((res) => {
          if (res.success) {
            this.stepList = res.result
            console.log(this.stepList)
          } else {
            this.$message.warning(res.message)
          }
        })
        this.rules.vin = [{ required: true, message: '请输入识别代码', trigger: 'blur' }, {
          message: '请输入正确的VIN码',
          pattern: new RegExp(/^[A-HJ-NPR-Z\d]{17}$/)
        }]
        this.rules.price = [{ required: true, message: '请输入车辆总价', trigger: 'blur' }]
        this.rules.deliveryTime = [{ required: true, message: '请选择交付时间', trigger: 'blur' }]
        this.rules.deliveryPlace = [{ required: true, message: '请选择交付地点', trigger: 'blur' }]
        this.rules.sellerId = [{ required: true, message: '请选择销售人员', trigger: 'blur' }]
      } else {
        this.rules.vin = []
        this.rules.price = []
        this.rules.deliveryTime = []
        this.rules.deliveryPlace = []
      }
      // 查看合同时切换成合同列表
      if (value == 1 || value == 3) {
        this.current = value
        this.width = 1050
      } else if (value == 2 || value == 0) {
        this.current = value
        this.width = 1000
      }
      this.visible = true
      console.log('当前状态：' + this.current)
    },

    close() {
      this.$emit('close')
      this.visible = false
      this.brandList = []
      this.modelList = []
      this.outsideColorList = []
      this.interiorColorList = []
      this.actionList = []
      this.selectDisabled = true
      this.isChecked = false
      this.signed = false
      if (this.editStatus == true) {
        this.model = {}
        this.isNeedOthers = ''
        this.editStatus = false
      }
      if (this.current !== 1) {
        this.$refs['ruleForm'].clearValidate()
      }
    },
    handleOk() {
      const that = this
      // this.$message.success('提交成功')
      // this.close()
      // 触发表单验证
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          that.confirmLoading = true
          let httpurl = '/sale/cxmSaleOrderInfo/addOrderInfo'
          let method = 'post'
          console.log(that.model)
          if (this.model.orderType == 2 && this.current == 0) {
            // let url = '/sale/cxmSaleContractProcess/add'
            // let data = {
            httpurl = '/sale/cxmSaleOrderInfo/addOrderInfo?isTransfer=true'
            this.model.processContractId = this.model.id //合同编号
            this.model.processCurrentHandlerId = this.model.step //当前处理人id
            this.model.processName = this.model.name + '-' + this.model.brand + '-' + this.model.carModel //流程名 生成规则 “客户姓名-车辆品牌-车辆型号”
            // }
            // let method = 'post'
            // httpAction(url, data, method)
            //   .then((res) => {
            //     if (res.success) {
            //       that.$message.success(res.message)
            //       that.$emit('ok')
            //     } else {
            //       that.$message.warning(res.message)
            //     }
            //   })
          }
          let formData = Object.assign(this.model)
          //时间格式化
          // formData.deliveryTime = formData.deliveryTime ? formData.deliveryTime.format('YYYY-MM-DD') : null

          httpAction(httpurl, formData, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
              this.model = {}
              that.close()
            })
        }
      })

    },
    handleCheck() {
      const that = this
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          that.confirmLoading = true
          let httpurl = '/sale/cxmSaleProcessAction/add'
          let method = 'post'
          this.check.doneBy = this.checkList.currentHandlerId
          this.check.finished = this.check.action
          console.log(this.check.finished)
          this.check.processId = this.checkList.id
          console.log(this.check)
          let formData = Object.assign(this.check)

          httpAction(httpurl, formData, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
              that.close()
            })
        }
      })
    },
    handleEdit() {
      const that = this
      // this.$message.success('提交成功')
      // this.close()
      // 触发表单验证
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          that.confirmLoading = true
          let httpurl = '/sale/cxmSaleOrderInfo/edit'
          let method = 'post'
          console.log(that.model)
          let formData = Object.assign(this.model)
          //时间格式化
          let turntoContract = false
          if (this.model.orderType == 1 && this.current == 0) {
            formData.orderType = 2
            turntoContract = true
            formData.processContractId = formData.id //合同编号
            formData.processCurrentHandlerId = formData.step //当前处理人id
            formData.processName = formData.name + '-' + formData.brand + '-' + formData.carModel //流程名 生成规则 “客户姓名-车辆品牌-车辆型号”
            httpurl = '/sale/cxmSaleOrderInfo/edit?isTransfer=true'
          }

          httpAction(httpurl, formData, method)
            .then((res) => {
              console.log(res)
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
                console.log(this.model.orderType, this.current)
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
              that.close()
            })
        }
      })

    },
    confirmSigned() {
      const that = this
      that.confirmLoading = true

      postAction('/sale/cxmSaleOrderInfo/confirmOrderInfo?id=' + this.model.id + '&confirmStatus=' + true)
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
          that.close()
        })
    },
    saveDraft() {
      const that = this
      this.form.validateFields((err, values) => {
        let formData = Object.assign(this.model, values)
        //时间格式化
        formData.orderDate = formData.orderDate ? formData.orderDate.format('YYYY-MM-DD HH:mm:ss') : null
        let httpurl = this.url.saveDraft

        console.log(JSON.stringify(formData))
        let Data = {}
        Data.btype = 'order'
        Data.content = JSON.stringify(formData)
        console.log(Data)
        httpAction(httpurl, Data, 'post')
          .then((res) => {
            if (res.success) {
              that.$message.success(res.message)
              that.$emit('ok')
            } else {
              that.$message.warning(res.message)
            }
          })
          .finally(() => {
            that.confirmLoading = false
            that.close()
          })
      })

    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .ant-form-item {
  margin-bottom: 10px;
}

/deep/ .ant-input-number-handler-wrap {
  display: none
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border: 1px solid #000;
  border-collapse: collapse;
}


.formBorder1st {
  border: 1px solid #000
}

.formBorder {
  border: 1px solid #000;
  border-top: none
}

.notRight {
  border-right: 1px solid #000;
}

.textarea-border {
  border-left: 1px solid #000;
}

.formInlineHeight {
  padding: 4px 5px;
  height: 30px;
}

.formInlineHeight_high {
  padding: 4px 5px;
}
</style>